<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<style>
    /*重新设置样式*/
    .form-control {
        width: 196px !important;
        height: 34px !important;
        padding: 10px !important;
    }

</style>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>库存联合查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>仓库类型</label>
                                    <select id="ityType" name="ityType" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 90px!important;">
                                        <option value="">全部</option>
                                        <option value="p">外购件库</option>
                                        <option value="m">原料库</option>
                                        <option value="h">成品库</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>项目编号</label>
                                    <input style="width: 123px" type="text" name="ityProCode" class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>项目名称</label>
                                    <input style="width: 123px" type="text" name="ityProName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>物料描述</label>
                                    <input style="width: 210px" type="text" name="ityMatDesc" class="form-control"
                                           placeholder="请输入物料描述">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>SAP物料编码</label>
                                    <input style="width: 210px" type="text" name="itySapCode" class="form-control"
                                           placeholder="请输入SAP物料编码">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>跟踪号</label>
                                    <input style="width: 108px" type="text" name="ityTrackCode" class="form-control"
                                           placeholder="请输入跟踪号">
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>生产状态</label>
                                    <select name="proProductionStatus" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 90px!important;">
                                        <option value="" selected="selected">全部</option>
                                        <option value="-1">无状态</option>
                                        <option value="1">未开始</option>
                                        <option value="2">执行中</option>
                                        <option value="3">已完成</option>
                                        <option value="4">取消</option>
                                        <option value="5">暂缓</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>在库类型</label>
                                    <select name="ityStockType" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 90px!important;">
                                        <option value="" selected="selected">请选择</option>
                                        <option value="1">库存在库</option>
                                        <option value="2">项目在库</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px; margin-bottom: 5px">
                                    <label>仓库</label>
                                    <select id="ityWhiId" name="ityWhiId" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 110px!important;">
                                    </select>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table" style="table-layout: fixed;"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var table;

    /**
     * 加载仓库列表
     * */
    function loadWhList() {
        $.post(ctx + 'common/warehouseInfo/listAll',
            {}
            , function (result) {
                $('#ityWhiId').empty();
                $('#ityWhiId').append('<option value="" selected="selected">全部</option>');
                for (var i = 0; i < result.data.rows.length; i++) {
                    $('#ityWhiId').append('<option value="' + result.data.rows[i].whiId + '"  >' + result.data.rows[i].whiName + '</option>');//selected="selected"是默认某一个仓库
                }
            }, '')
    }

    /**
     * 有权看钱没权看星
     * */
    function displayMoney(value) {
        if (hasP('overview:unionqueryamount:view')) {
            return value;
        } else {
            return '***';
        }
    }

    /**
     * 就绪函数
     */
    $(function () {
        loadWhList();

        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "overview/inventory/list",
            pageSize: 300,
            showColumns: true,
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'ityId', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    title: '物料描述', field: 'ityMatDesc', width: '100', formatter: function (value, row, index) {
                        return '<p  style="word-wrap: break-word;width: 90px">' + value + '</p>';
                    }
                },
                {title: 'SAP<br>物料编码', field: 'itySapCode', width: '100'},
                {
                    title: '数量', field: 'ityNum', width: '50', formatter: function (value, row, index) {
                        if (value === null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 40px">' + value + '</p>';
                    }
                },
                {title: '单位', field: 'ityNumUnit', width: '50'},//数量单位
                {
                    title: '单价<br>（元）', field: 'ityPrice', width: '55', formatter: function (value, row, index) {
                        if (value === null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 50px">' + displayMoney(value) + '</p>';
                    }
                },
                {
                    title: '金额<br>（元）', field: 'ityAmount', width: '55', formatter: function (value, row, index) {
                        if (value === null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 50px">' + displayMoney(value) + '</p>';
                    }
                },
                {title: '项目编号', field: 'ityProCode', width: '78'},
                {
                    title: '项目名称', field: 'ityProName', width: '100', formatter: function (value, row, index) {
                        if (value == null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 90px">' + value + '</p>';
                    }
                },
                {title: '生产状态', field: 'proStatusText', width: '75'},
                {title: '跟踪号', field: 'ityTrackCode', width: '95'},
                {
                    title: '在库类型', field: 'ityStockType', width: '75', formatter: function (value, row, index) {
                        if (value == 1) {
                            return "库存在库";
                        }
                        if (value == 2) {
                            return "项目在库";
                        }
                    }
                },
                {
                    title: '备注', field: 'ityRemark', width: '55', formatter: function (value, row, index) {
                        if (value == null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 50px">' + value + '</p>';
                    }
                },
                {
                    title: '仓库', field: 'whiName', width: '55', formatter: function (value, row, index) {
                        if (value == null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 50px">' + value + '</p>';
                    }
                },
                {
                    title: '区位', field: 'ityPosition', width: '55', formatter: function (value, row, index) {
                        if (value == null) {
                            value = '';
                        }
                        return '<p  style="word-wrap: break-word;width: 50px">' + value + '</p>';
                    }
                },
                {title: '记账日期', field: 'ityBookkeepingDate', width: '100'}
            ]
        });

        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });
    });
</script>
</body>
</html>